import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';
import { weChatList } from '@apps/ant-bus/src/views/business/platformManage/wechat/data/api';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '商品名称',
    dataIndex: 'goodsName',
    width: 150,
  },
  {
    title: '封面图',
    dataIndex: 'coverImg',
    width: 70,
    customRender: render.renderImage,
    isExport: false,
  },
  {
    title: '生成数量',
    dataIndex: 'goodsNum',
    width: 80,
  },
  {
    title: '券码',
    dataIndex: 'qrCode',
    width: 150,
  },
  {
    title: '支付方式',
    dataIndex: 'paywayName',
    width: 140,
  },
  {
    title: '金额',
    dataIndex: 'payAmount',
    width: 100,
  },
  {
    title: '使用状态',
    dataIndex: 'useState',
    width: 100,
    align: 'center',
    dictData: [
      { label: '未使用', value: 1 },
      { label: '已使用', value: 2 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '退款状态',
    dataIndex: 'refundState',
    width: 100,
    align: 'center',
    dictData: [
      { label: '未申请', value: 0 },
      { label: '申请中', value: 1 },
      { label: '已取消', value: 2 },
      { label: '已退款', value: 3 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '有效期',
    dataIndex: 'expireDate',
    width: 180,
  },
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'goodsName',
    label: '商品名称',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'qrCode',
    label: '商品券码',
    component: 'Input',
    colProps: { span: 5 },
  },
];

export const sendMessageFormSchema: FormSchema[] = [
  {
    label: '用户物品Id',
    field: 'userGoodsId',
    component: 'Input',
    required: true,
    show: false,
  },
  {
    label: '会员电话',
    field: 'quMaUserMobile',
    component: 'Input',
    required: true,
    rules: [
      { required: true, message: '请输入手机号' },
      { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
    ],
  },
  {
    label: '所属公众号',
    field: 'weChatId',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: weChatList,
      labelField: 'weChatName',
      valueField: 'weChatId',
      immediate: true,
    },
  },
  {
    label: '备注',
    field: 'userRemark',
    component: 'InputTextArea',
  },
];
